﻿@model ArticleEditDto
@Html.Extra()
@{
    Layout = "~/Views/Shared/OA/_Form.cshtml";
    var catalog = (Catalog)ViewBag.Catalog;
    var catalogKey = catalog.Key;
    var config = SerializationHelper.JsonDeserialize
    <JObject>(catalog.Config);
    var create = ViewContext.RouteData.Values["Action"].ToString() == "Create";
    //是否返回当前页面
    var isBackThis = Request["back"] == "thisBack";
    var qphId = ConvertHelper.ToGuid(Request["qphId"]);
    var qph = IoCHeler.Resolve<IArticleAppService>().GetArticle(qphId);
    if (isBackThis)
    {
        AssertHelper.NoPass(qph == null, "未找到汽派号");
    }
    var user = ManagerAuthorization.Current.User;
    //是否汽湃号商户
    var isQPHSH = user.Roles.Any(x => x.Key == "QPHSH");
}
@section Toolbar
        {

    @if (isBackThis)
    {
        <button class="k-button" onclick="save()"><span class="i i-save"></span>保存</button>
        <button class="k-button" onclick="backThis()"><span class="i i-backThis"></span>返回</button>

    }
    else
    {
        @Html.MyNet().Button(new ButtonOptions { Text = "保存", Click = "save" })

        @Html.MyNet().Button(new ButtonOptions { Text = "返回", Click = "cancel1(1)" })
        <!--@Html.MyNet().Button(new ButtonOptions { Text = "返回", Click = "back" })-->
    }
}
@section Main
        {
    @Html.HiddenFor(model => model.Id)
    @Html.HiddenFor(model => model.Key)
    @Html.HiddenFor(model => model.ObjectId)
    @Html.HiddenFor(model => model.CatalogIds)
    <script>
        var editText = "";
    </script>

    <table width="97%" style="position: relative">
        <div class="pop-up-model">
            <div class="img-action-wrap">
                <div class="header">
                    <span>编辑图片</span>
                </div>
                <div class="edit-container">
                    <div class="pannel">
                        <img style="max-width: 100; display: none;" id="image" src="" alt="">
                    </div>
                    <div class="menu">
                        <div class="menu-item">
                            <p> 裁剪尺寸</p>
                            <div class="menu-btn" id="size-btn">
                                <span data-index="1">自定义</span>
                                <span data-index="2">2:1</span>
                                <span data-index="2">3:2</span>
                                <span data-index="3">4:3</span>
                                <span class="active" data-index="4">16:9</span>
                            </div>
                        </div>

                        <div class="menu-item">
                            <p>底图操作</p>
                            <div class="menu-btn" id="base-img-btn">
                                <span>旋转</span>
                                <span>缩小</span>
                                <span>放大</span>
                                <br />
                                <span>翻转X轴</span>
                                <span>翻转Y轴</span>
                                <br />
                                <span>上移</span>
                                <span>下移</span>
                                <span>左移</span>
                                <span>右移</span>
                            </div>
                        </div>
                        <div class="menu-item">
                            <p>图片操作</p>
                            <div class="menu-btn" id="preview-img-btn">
                                <input id="file-up" style="display: none" type="file">
                                <span>本地上传</span>
                                <span>预览</span>
                                <span>上传封面</span>
                                <span>设置封面</span>
                            </div>
                        </div>
                        <div class="menu-item"
                             style="position: absolute; bottom: 10px; right: 0;left: 0;">
                            <div class="menu-btn" id="action-img-btn">
                                <span style="background-color: #fff;border-color: #dcdee2;color: #515a6e;">取消</span>
                                <span>保存</span>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="footer"></div>
            </div>
        </div>
        <col width="110px" />
        <tr>
            <th>
                ID
            </th>
            <td>
                @Model.Id
            </td>
        </tr>
        <tr>
            <th>
                文章Key
            </th>
            <td>
                @Model.Key
            </td>
        </tr>
        @if (config.GetBoolean("Catalog_EditVisible"))
        {
            <tr>
                <th>
                    <b>*</b>@Html.LabelFor(model => model.CatalogId, "栏目")
                </th>
                <td>
                    @Html.MyNet().DropDownTreeFor(model => model.CatalogId, Url.Action("ReadForParent", "Catalog", new
                    {
                        ParentKey = "Article"
                    }), "请选择栏目", new ValidateOptions
                    {
                        RequiredError = "请选择栏目"
                    }, null, "onSelect")
                    @Html.MyNet().ValidationMessageFor(model => model.CatalogId)
                    <script>
                        function onSelect(value) {
                            location = "/CMS/Article/Create?CatalogId=" + value;
                        }
                    </script>
                </td>
            </tr>
        }
        else
        {
            @Html.HiddenFor(model => model.CatalogId)
        }
        @if (config.GetBoolean("Receipt_EditVisible"))
        {
            <tr>
                <th>
                    @Html.LabelFor(model => model.Receiptants, "接收人")
                </th>
                <td>
                    @Html.MyNet().HumanPickerFor(model => model.Receiptants)
                    (为空时代表全体员工)
                    @if (create)
                    {
                        Model.IsNotify = config.GetBoolean("Receipt_IsNotify");
                    }
                    @Html.CheckBoxFor(model => model.IsNotify)
                    @Html.LabelFor(model => model.IsNotify, "是否通知接收人")
                </td>
            </tr>
        }
        @{
            if (create)
            {
                Model.Title = config.GetString("Title_Value");
            }
            var title_Display = string.IsNullOrEmpty(config.GetString("Title_Display")) ? "标题" :
            config.GetString("Title_Display");
            <tr>
                <th>
                    <b>*</b>@Html.LabelFor(model => model.Title, title_Display)
                </th>
                <td>
                    @Html.MyNet().TextBoxFor(model => model.Title, new ValidateOptions
                    {
                        RequiredError = "请输入" + title_Display,
                        LengthMax = 256
                    })
                    @Html.MyNet().ValidationMessageFor(model => model.Title)
                </td>
            </tr>
        }
        @if (config.GetBoolean("FullTitle_EditVisible"))
        {
            if (create)
            {
                Model.FullTitle = config.GetString("FullTitle_Value");
            }
            var FullTitle_Display = string.IsNullOrEmpty(config.GetString("FullTitle_Display")) ? "完整标题" :
            config.GetString("FullTitle_Display");
            var FullTitle_Required = config.GetBoolean("FullTitle_Required");
            <tr>
                <th>
                    @if (FullTitle_Required)
                    {
                        <b>*</b>
                    }
                    @Html.LabelFor(model => model.FullTitle, FullTitle_Display)
                </th>
                <td>
                    @Html.MyNet().TextBoxFor(model => model.FullTitle, !FullTitle_Required ? null : new ValidateOptions
                    {
                        RequiredError = "请输入" + FullTitle_Display,
                        LengthMax = 256
                    })
                    @Html.MyNet().ValidationMessageFor(model => model.FullTitle)
                </td>
            </tr>
        }
        @if (config.GetBoolean("SubTitle_EditVisible"))
        {
            if (create)
            {
                Model.SubTitle = config.GetString("SubTitle_Value");
            }
            var SubTitle_Display = string.IsNullOrEmpty(config.GetString("SubTitle_Display")) ? "子标题" :
            config.GetString("SubTitle_Display");
            var SubTitle_Required = config.GetBoolean("SubTitle_Required");
            <tr>
                <th>
                    @if (SubTitle_Required)
                    {
                        <b>*</b>
                    }
                    @Html.LabelFor(model => model.SubTitle, SubTitle_Display)
                </th>
                <td>
                    @Html.MyNet().TextBoxFor(model => model.SubTitle, !SubTitle_Required ? null : new ValidateOptions
                    {
                        RequiredError = "请输入" + SubTitle_Display,
                        LengthMax = 256
                    })
                    @Html.MyNet().ValidationMessageFor(model => model.SubTitle)
                </td>
            </tr>
        }
        @if (config.GetBoolean("TitleStyle_EditVisible"))
        {
            if (create)
            {
                Model.TitleStyle = config.GetString("TitleStyle_Value");
            }
            <tr>
                <th>
                    @Html.LabelFor(model => model.TitleStyle,
                                                                                                                                                            string.IsNullOrEmpty(config.GetString("TitleStyle_Display")) ?
                                                                                                                                                            "标题样式" :
                                                                                                                                                            config.GetString("TitleStyle_Display"))
                </th>
                <td class="checkbox titleStyle">
                    @Html.HiddenFor(model => model.TitleStyle)
                    <input id="bold" type="checkbox" />
                    <label for="bold">
                        加粗
                    </label>
                    <input id="red" type="checkbox" />
                    <label for="red">
                        加红
                    </label>
                    <input id="italic" type="checkbox" />
                    <label for="italic">
                        斜体
                    </label>
                    <input id="underline" type="checkbox" />
                    <label for="underline">
                        下划线
                    </label>
                    <script>
                        jQuery(function myfunction() {
                            var style = $("#TitleStyle").val().toLowerCase();
                            $("#bold")[0].checked = style.indexOf("bold") > 0;
                            $("#red")[0].checked = style.indexOf("red") > 0;
                            $("#italic")[0].checked = style.indexOf("italic") > 0;
                            $("#underline")[0].checked = style.indexOf("underline") > 0;

                            $(".titleStyle :checkbox").click(function myfunction() {
                                style = "";
                                if ($("#bold")[0].checked)
                                    style += "font-weight: bold; ";
                                if ($("#red")[0].checked)
                                    style += "color: red; ";
                                if ($("#italic")[0].checked)
                                    style += "font-style: italic; ";
                                if ($("#underline")[0].checked)
                                    style += "text-decoration: underline; ";

                                $("#TitleStyle").val(style);
                            });
                        });
                    </script>
                </td>
            </tr>
        }
        @if (config.GetBoolean("Keyword_EditVisible"))
        {
            if (create)
            {
                Model.Keyword = config.GetString("Keyword_Value");
            }
            var Keyword_Display = string.IsNullOrEmpty(config.GetString("Keyword_Display")) ? "关键字" :
            config.GetString("Keyword_Display");
            var Keyword_Required = config.GetBoolean("Keyword_Required");
            <tr>
                <th>
                    @if (Keyword_Required)
                    {
                        <b>*</b>
                    }
                    @Html.LabelFor(model => model.Keyword, Keyword_Display)
                </th>
                <td>
                    @Html.MyNet().TextBoxFor(model => model.Keyword, !Keyword_Required ? null : new ValidateOptions
                    {
                        RequiredError = "请输入" + Keyword_Display,
                        LengthMax = 256
                    })
                    @Html.MyNet().ValidationMessageFor(model => model.Keyword)
                </td>
            </tr>
        }
        @if (config.GetBoolean("Tag_EditVisible"))
        {
            if (create)
            {
                Model.Tag = config.GetString("Tag_Value");
            }
            var Tag_Display = string.IsNullOrEmpty(config.GetString("Tag_Display")) ? "标签" :
            config.GetString("Tag_Display");
            var Tag_Required = config.GetBoolean("Tag_Required");
            <tr>
                <th>
                    @if (Tag_Required)
                    {
                        <b>*</b>
                    }
                    @Html.LabelFor(model => model.Tag, Tag_Display)
                </th>
                <td>
                    @Html.MyNet().TextBoxFor(model => model.Tag, !Tag_Required ? null : new ValidateOptions
                    {
                        RequiredError = "请输入" + Tag_Display,
                        LengthMax = 256
                    })
                    @Html.MyNet().ValidationMessageFor(model => model.Tag)
                </td>
            </tr>
        }
        @if (!isQPHSH)
        {
            if (config.GetBoolean("Origin_EditVisible"))
            {
                if (create)
                {
                    Model.Origin = config.GetString("Origin_Value");
                }
                var Origin_Display = string.IsNullOrEmpty(config.GetString("Origin_Display")) ? "来源" :
                config.GetString("Origin_Display");
                var Origin_Required = config.GetBoolean("Origin_Required");
                <tr>
                    <th>
                        @if (Origin_Required)
                        {
                            <b>*</b>
                        }
                        @Html.LabelFor(model => model.Origin, Origin_Display)
                    </th>
                    <td>
                        @if (catalog.IsQPH)
                        {
                            if (isBackThis)
                            {
                                @Html.Hidden("Origin", qph.Id)
                                @qph.Title
                            }
                            else
                            {
                                @Html.MyNet().DropDownListFor(model => model.Origin, "/cms/article/ReadForQPH?catalogKey=qphgl",
                                                                                                                                                                        "id", "text", "请选择" + Origin_Display, !Origin_Required ? null : new ValidateOptions
                                                                                                                                                                        {
                                                                                                                                                                            RequiredError = "请选择" + Origin_Display,
                                                                                                                                                                            LengthMax = 256
                                                                                                                                                                        })
                            }

                            @Html.MyNet().ValidationMessageFor(model => model.Origin)
                        }
                        else
                        {
                            @Html.MyNet().TextBoxFor(model => model.Origin, !Origin_Required ? null : new ValidateOptions
                            {
                                RequiredError = "请输入" + Origin_Display,
                                LengthMax = 256
                            })
                            @Html.MyNet().ValidationMessageFor(model => model.Origin)
                        }
                    </td>
                </tr>
            }
        }
        else
        {
            @Html.MyNet().HiddenFor(model => model.Origin)
        }

        @if (config.GetBoolean("Author_EditVisible"))
        {
            if (create)
            {
                Model.Author = config.GetString("Author_Value");
            }
            var Author_Display = string.IsNullOrEmpty(config.GetString("Author_Display")) ? "作者" :
            config.GetString("Author_Display");
            var Author_Required = config.GetBoolean("Author_Required");
            <tr>
                <th>
                    @if (Author_Required)
                    {
                        <b>*</b>
                    }
                    @Html.LabelFor(model => model.Author, Author_Display)
                </th>
                <td>
                    @Html.MyNet().TextBoxFor(model => model.Author, !Author_Required ? null : new ValidateOptions
                    {
                        RequiredError = "请输入" + Author_Display,
                        LengthMax = 256
                    })
                    @Html.MyNet().ValidationMessageFor(model => model.Author)
                </td>
            </tr>
        }


        @if (config.GetBoolean("IsOriginality_EditVisible"))
        {
            if (create)
            {
                Model.IsOriginality = config.GetBoolean("IsOriginality_Value");
            }
            var IsOriginality_Display = string.IsNullOrEmpty(config.GetString("IsOriginality_Display")) ? "是否原创" :
            config.GetString("IsOriginality_Display");
            var IsOriginality_Required = config.GetBoolean("IsOriginality_Required");
            <tr>
                <th>
                    @if (IsOriginality_Required)
                    {
                        <b>*</b>
                    }
                    @Html.LabelFor(model => model.IsOriginality, IsOriginality_Display)
                </th>
                <td>
                    @Html.MyNet().CheckBoxFor(model => model.IsOriginality)
                </td>
            </tr>
        }

        @if (config.GetBoolean("Type_EditVisible"))
        {
            if (create)
            {
                Model.Type = config.GetInt("Type_Value");
            }
            var Type_Display = string.IsNullOrEmpty(config.GetString("Type_Display")) ? "文章类型" : config.GetString("Type_Display");
            var Type_Required = config.GetBoolean("Type_Required");
            <tr>
                <th>
                    @if (Type_Required)
                    {
                        <b>*</b>
                    }
                    @Html.LabelFor(model => model.Type, Type_Display)
                </th>
                <td>
                    <span id="Type">
                        <input id="TypeWZ" name="TypeGroup" type="radio" value="0" @(Model.Type == 0 ? "checked" : "") onclick="jQuery('input[name=Type]').val(jQuery(this).val())">
                        <label for="TypeWZ" style="margin-right: 10px;">图文</label>
                        <input id="TypeViedo" name="TypeGroup" type="radio" value="1" @(Model.Type == 1 ? "checked" : "") onclick="jQuery('input[name=Type]').val(jQuery(this).val())">
                        <label for="TypeViedo" style="margin-right: 10px;">视频</label>
                        @*<input id="TypeLive" name="TypeGroup" type="radio" value="2" @(Model.Type == 2 ? "checked" : "") onclick="jQuery('input[name=Type]').val(jQuery(this).val())">
                            <label for="TypeLive" style="margin-right: 10px;">直播</label>*@
                        <input name="Type" type="hidden" value="@Model.Type">
                    </span>
                    @Html.MyNet().ValidationMessageFor(model => model.Type)
                </td>
            </tr>
        }
        else
        {
            <input name="Type" type="hidden" value="@Model.Type">
        }

        @if (config.GetBoolean("TitleImageType_EditVisible"))
        {
            if (create)
            {
                Model.TitleImageType = config.GetInt("TitleImageType_Value");
            }
            var TitleImageType_Display = string.IsNullOrEmpty(config.GetString("TitleImageType_Display")) ? "标题图展示" : config.GetString("TitleImageType_Display");
            var TitleImageType_Required = config.GetBoolean("TitleImageType_Required");
            <tr>
                <th>
                    @if (TitleImageType_Required)
                    {
                        <b>*</b>
                    }
                    @Html.LabelFor(model => model.TitleImageType, TitleImageType_Display)
                </th>
                <td>
                    <span id="TitleImageType">
                        <input id="TitleImageTypeWZ" name="TitleImageTypeGroup" type="radio" value="0" @(Model.TitleImageType == 0 ? "checked" : "") onclick="jQuery('input[name=TitleImageType]').val(jQuery(this).val())">
                        <label for="TitleImageTypeWZ" style="margin-right: 10px;">1图</label>
                        <input id="TitleImageTypeViedo" name="TitleImageTypeGroup" type="radio" value="1" @(Model.TitleImageType == 1 ? "checked" : "") onclick="jQuery('input[name=TitleImageType]').val(jQuery(this).val())">
                        <label for="TitleImageTypeViedo" style="margin-right: 10px;">3图</label>
                        <input name="TitleImageType" type="hidden" value="@Model.TitleImageType">
                    </span>
                    @Html.MyNet().ValidationMessageFor(model => model.TitleImageType)
                </td>
            </tr>
        }


        @if (config.GetBoolean("LiveStartTime_EditVisible"))
        {
            if (create)
            {
                Model.LiveStartTime = config.GetDateTimeNullable("LiveStartTime_Value");
            }
            var LiveStartTime_Display = string.IsNullOrEmpty(config.GetString("LiveStartTime_Display")) ? "直播开始时间" : config.GetString("LiveStartTime_Display");
            var LiveStartTime_Required = config.GetBoolean("LiveStartTime_Required");
            <tr>
                <th>
                    @if (LiveStartTime_Required)
                    {
                        <b>*</b>
                    }
                    @Html.LabelFor(model => model.LiveStartTime, LiveStartTime_Display)
                </th>
                <td>
                    @Html.MyNet().DateTimePickerFor(model => model.LiveStartTime, new DateTimeOptions { }, !LiveStartTime_Required ? null : new ValidateOptions
                    {
                        RequiredError = "请输入" + LiveStartTime_Display
                    })
                    @Html.MyNet().ValidationMessageFor(model => model.LiveStartTime)
                </td>
            </tr>
        }

        @if (config.GetBoolean("LiveEndTime_EditVisible"))
        {
            if (create)
            {
                Model.LiveEndTime = config.GetDateTimeNullable("LiveEndTime_Value");
            }
            var LiveEndTime_Display = string.IsNullOrEmpty(config.GetString("LiveEndTime_Display")) ? "直播结束时间" : config.GetString("LiveEndTime_Display");
            var LiveEndTime_Required = config.GetBoolean("LiveEndTime_Required");
            <tr>
                <th>
                    @if (LiveEndTime_Required)
                    {
                        <b>*</b>
                    }
                    @Html.LabelFor(model => model.LiveEndTime, LiveEndTime_Display)
                </th>
                <td>
                    @Html.MyNet().DateTimePickerFor(model => model.LiveEndTime, new DateTimeOptions { }, !LiveEndTime_Required ? null : new ValidateOptions
                    {
                        RequiredError = "请输入" + LiveEndTime_Display
                    })
                    @Html.MyNet().ValidationMessageFor(model => model.LiveEndTime)

                    <script>
                        document.getElementById('LiveEndTime').onblur = function (e) {
                            var liveEndTime = $('#LiveEndTime').val();
                            console.log(liveEndTime)
                            if (liveEndTime) {
                                $.ajax({
                                url: "/cms/article/GetLiveQRCode",
                                data: { id: "@Model.Id", liveEndTime: liveEndTime},
                                success: function (result) {
                                    $('#LivePushAddr').val(result.Item1);
                                    $('#qrcode').html('');
                                    new QRCode(document.getElementById("qrcode"), {text: result.Item1,
                                    width: 128,
                                    height: 128
                                    });

                                    $('#LivePlayAddr').val(result.Item2);
                                }
                               })
                            }
                        }
                    </script>
                </td>
            </tr>
        }

        @if (config.GetBoolean("LiveStatus_EditVisible"))
        {
            if (create)
            {
                Model.LiveStatus = config.GetInt("LiveStatus_Value");
            }
            var LiveStatus_Display = string.IsNullOrEmpty(config.GetString("LiveStatus_Display")) ? "直播状态" : config.GetString("LiveStatus_Display");
            var LiveStatus_Required = config.GetBoolean("LiveStatus_Required");
            <tr>
                <th>
                    @if (LiveStatus_Required)
                    {
                        <b>*</b>
                    }
                    @Html.LabelFor(model => model.LiveStatus, LiveStatus_Display)
                </th>
                <td>
                    <span id="LiveStatus">
                        <input id="LiveStatusWZ" name="LiveStatusGroup" type="radio" value="0" @(Model.LiveStatus == 0 ? "checked" : "") onclick="jQuery('input[name=LiveStatus]').val(jQuery(this).val())">
                        <label for="LiveStatusWZ" style="margin-right: 10px;">未开始</label>
                        <input id="LiveStatusViedo" name="LiveStatusGroup" type="radio" value="1" @(Model.LiveStatus == 1 ? "checked" : "") onclick="jQuery('input[name=LiveStatus]').val(jQuery(this).val())">
                        <label for="LiveStatusViedo" style="margin-right: 10px;">进行中</label>
                        <input id="LiveStatusLive" name="LiveStatusGroup" type="radio" value="2" @(Model.LiveStatus == 2 ? "checked" : "") onclick="jQuery('input[name=LiveStatus]').val(jQuery(this).val())">
                        <label for="LiveStatusLive" style="margin-right: 10px;">已结束</label>
                        <input name="LiveStatus" type="hidden" value="@Model.LiveStatus">
                    </span>
                    @Html.MyNet().ValidationMessageFor(model => model.LiveStatus)
                </td>
            </tr>
        }

        @if (config.GetBoolean("LivePushAddr_EditVisible"))
        {
            //if (create)
            //{
            //    Model.LivePushAddr = config.GetString("LivePushAddr_Value");
            //}
            var LivePushAddr_Display = string.IsNullOrEmpty(config.GetString("LivePushAddr_Display")) ? "直播推流地址" : config.GetString("LivePushAddr_Display");
            var LivePushAddr_Required = config.GetBoolean("LivePushAddr_Required");
            <tr class="liveInfo" style="display:@(Model.LiveStatus == 2?"none":"")">
                <th>
                    @if (LivePushAddr_Required)
                    {
                        <b>*</b>
                    }
                    @Html.LabelFor(model => model.LivePushAddr, LivePushAddr_Display)
                </th>
                <td>
                    @Html.MyNet().TextBoxFor(model => model.LivePushAddr, !LivePushAddr_Required ? null : new ValidateOptions
                    {
                        RequiredError = "请输入" + LivePushAddr_Display,
                        LengthMax = 256
                    })

                    @Html.MyNet().ValidationMessageFor(model => model.LivePushAddr)

                    <span id="qrcode" style="margin-top:5px;"></span>
                    <script type="text/javascript">
                        new QRCode(document.getElementById("qrcode"), {
                            text: '@Html.Raw(Model.LivePushAddr)',
                            width: 128,
                            height: 128
                        });
                    </script>
                </td>
            </tr>
        }
        @if (config.GetBoolean("LivePlayAddr_EditVisible"))
        {
            //if (create)
            //{
            //    Model.LivePlayAddr = config.GetString("LivePlayAddr_Value");
            //}
            var LivePlayAddr_Display = string.IsNullOrEmpty(config.GetString("LivePlayAddr_Display")) ? "播放地址" : config.GetString("LivePlayAddr_Display");
            var LivePlayAddr_Required = config.GetBoolean("LivePlayAddr_Required");
            <tr class="liveInfo" style="display:@(Model.LiveStatus == 2?"none":"")">
                <th>
                    @if (LivePlayAddr_Required)
                    {
                        <b>*</b>
                    }
                    @Html.LabelFor(model => model.LivePlayAddr, LivePlayAddr_Display)
                </th>
                <td>
                    @Html.MyNet().TextBoxFor(model => model.LivePlayAddr, !LivePlayAddr_Required ? null : new ValidateOptions
                    {
                        RequiredError = "请输入" + LivePlayAddr_Display,
                        LengthMax = 256
                    })
                    @Html.MyNet().ValidationMessageFor(model => model.LivePlayAddr)
                </td>
            </tr>
        }

        @if (config.GetBoolean("LiveRePlayAddr_EditVisible"))
        {
            if (create)
            {
                Model.LiveRePlayAddr = config.GetString("LiveRePlayAddr_Value");
            }
            var LiveRePlayAddr_Display = string.IsNullOrEmpty(config.GetString("LiveRePlayAddr_Display")) ? "录播地址" : config.GetString("LiveRePlayAddr_Display");
            var LiveRePlayAddr_Required = config.GetBoolean("LiveRePlayAddr_Required");
            <tr>
                <th>
                    @if (LiveRePlayAddr_Required)
                    {
                        <b>*</b>
                    }
                    @Html.LabelFor(model => model.LiveRePlayAddr, LiveRePlayAddr_Display)
                </th>
                <td>
                    @Html.MyNet().TextBoxFor(model => model.LiveRePlayAddr, !LiveRePlayAddr_Required ? null : new ValidateOptions
                    {
                        RequiredError = "请输入" + LiveRePlayAddr_Display,
                        LengthMax = 256
                    })
                    @Html.MyNet().ValidationMessageFor(model => model.LiveRePlayAddr)
                </td>
            </tr>
        }

        @if (config.GetBoolean("TransferUrl_EditVisible"))
        {
            if (create)
            {
                Model.TransferUrl = config.GetString("TransferUrl_Value");
            }
            var TransferUrl_Display = string.IsNullOrEmpty(config.GetString("TransferUrl_Display")) ? "转向链接" :
            config.GetString("TransferUrl_Display");
            var TransferUrl_Required = config.GetBoolean("TransferUrl_Required");
            <tr>
                <th>
                    @if (TransferUrl_Required)
                    {
                        <b>*</b>
                    }
                    @Html.LabelFor(model => model.TransferUrl, TransferUrl_Display)
                </th>
                <td>
                    @Html.MyNet().TextBoxFor(model => model.TransferUrl, !TransferUrl_Required ? null : new
                                                                                                                                                            ValidateOptions
                    {
                        RequiredError = "请输入" + TransferUrl_Display,
                        LengthMax = 256
                    })
                    @Html.MyNet().ValidationMessageFor(model => model.TransferUrl)
                </td>
            </tr>
        }
        @if (config.GetBoolean("TitleImage_EditVisible"))
        {
            var TitleImage_Display = string.IsNullOrEmpty(config.GetString("TitleImage_Display")) ? "标题图片" :
            config.GetString("TitleImage_Display");
            var TitleImage_Required = config.GetBoolean("TitleImage_Required");
            <tr>
                <th>
                    @if (TitleImage_Required)
                    {
                        <b>*</b>
                    }
                    @Html.LabelFor(model => model.TitleImageUrl, TitleImage_Display)
                </th>
                <td>


                    <div id="oneImage" style="display:@(Model.TitleImageType == 0?"block":"none")">
                        <input id="TitleImageUrl" name="TitleImageUrl" style="display: none"
                               value="@Html.Raw(Model.TitleImageUrl)" type="text">
                        <span class="span-btn" id="TitleImageUrlBtn">上传图片</span>
                        <img id="TitleImageUrlImg"
                             style="width: 200px; min-height: 100px; margin-top: 10px;background: #f5f5f5"
                             src="@Html.Raw(Model.TitleImageUrl)" alt="">
                    </div>

                    @if (catalogKey != "qphgl")
                    {
                        <div id="moreImage" style="display:@(Model.TitleImageType == 1?"block":"none")">
                            <div style="display:inline-block ">
                                <input id="TitleImageUrl1" name="TitleImageUrl1" style="display: none"
                                       value="@Html.Raw(Model.TitleImageUrl1)" type="text">
                                <span class="span-btn" id="TitleImageUrl1Btn">上传图片</span>
                                <img id="TitleImageUrl1Img"
                                     style="width: 200px; min-height: 100px; margin-top: 10px;background: #f5f5f5"
                                     src="@Html.Raw(Model.TitleImageUrl1)" alt="">
                            </div>

                            <div style="display:inline-block ">
                                <input id="TitleImageUrl2" name="TitleImageUrl2" style="display: none"
                                       value="@Html.Raw(Model.TitleImageUrl2)" type="text">
                                <span class="span-btn" id="TitleImageUrl2Btn">上传图片</span>
                                <img id="TitleImageUrl2Img"
                                     style="width: 200px; min-height: 100px; margin-top: 10px;background: #f5f5f5"
                                     src="@Html.Raw(Model.TitleImageUrl2)" alt="">
                            </div>

                            <div style="display:inline-block ">
                                <input id="TitleImageUrl3" name="TitleImageUrl3" style="display: none"
                                       value="@Html.Raw(Model.TitleImageUrl3)" type="text">
                                <span class="span-btn" id="TitleImageUrl3Btn">上传图片</span>
                                <img id="TitleImageUrl3Img"
                                     style="width: 200px; min-height: 100px; margin-top: 10px;background: #f5f5f5"
                                     src="@Html.Raw(Model.TitleImageUrl3)" alt="">
                            </div>

                        </div>
                    }


                    @*<input id="TitleImageUrl" name="TitleImageUrl" style="display: none"
                               value="@Html.Raw(Model.TitleImageUrl)" type="text">
                        <span class="span-btn" id="TitleImageUrlBtn">上传图片</span>
                        <img id="TitleImageUrlImg"
                             style="width: 200px; min-height: 100px; margin-top: 10px;background: #f5f5f5"
                             src="@Html.Raw(Model.TitleImageUrl)" alt="">*@

                    @* @Html.MyNet().UploadFor(model => model.TitleImageUrl, new UploadOptions
                        {
                        AttachmentKey = Model.Id,
                        AttachmentTypeKey = "CMS_ArticleTitleImage",
                        UploadMode = UploadMode.ImageSingle,
                        ImageWidth = config.GetIntNullable("TitleImage_Width"),
                        ImageHeight = config.GetIntNullable("TitleImage_Height"),
                        PreviewImageWidth = config.GetIntNullable("TitleImage_PreviewWidth"),
                        PreviewImageHeight = config.GetIntNullable("TitleImage_PreviewHeight"),
                        }, !TitleImage_Required ? null : new ValidateOptions
                        {
                        RequiredError = "请上传" + TitleImage_Display
                        })
                        @Html.MyNet().ValidationMessageFor(model => model.TitleImageUrl)
                    *@
                </td>
            </tr>
        }
        @if (config.GetBoolean("ImageUrl_EditVisible"))
        {
            var ImageUrl_Display = string.IsNullOrEmpty(config.GetString("ImageUrl_Display")) ? "图片" :
            config.GetString("ImageUrl_Display");
            var ImageUrl_Required = config.GetBoolean("ImageUrl_Required");
            <tr>
                <th>
                    @if (ImageUrl_Required)
                    {
                        <b>*</b>
                    }
                    @Html.LabelFor(model => model.ImageUrl, ImageUrl_Display)
                </th>
                <td>
                    <input id="ImageUrl" name="ImageUrl" style="display: none" value="@Html.Raw(Model.ImageUrl)"
                           type="text">
                    <span class="span-btn" id="ImageUrlBtn">上传图片</span>
                    <img id="ImageUrlImg" style="width: 200px; min-height: 100px; margin-top: 10px;background: #f5f5f5"
                         src="@Html.Raw(Model.ImageUrl)" alt="">

                    @* @Html.MyNet().UploadFor(model => model.ImageUrl, new UploadOptions
                        {
                        AttachmentKey = Model.Id,
                        AttachmentTypeKey = "CMS_ArticleImage",
                        UploadMode = UploadMode.ImageSingle,
                        ImageWidth = config.GetIntNullable("ImageUrl_Width"),
                        ImageHeight = config.GetIntNullable("ImageUrl_Height"),
                        PreviewImageWidth = config.GetIntNullable("ImageUrl_PreviewWidth"),
                        PreviewImageHeight = config.GetIntNullable("ImageUrl_PreviewHeight"),
                        }, !ImageUrl_Required ? null : new ValidateOptions
                        {
                        RequiredError = "请上传" + ImageUrl_Display
                        })
                        @Html.MyNet().ValidationMessageFor(model => model.ImageUrl) *@
                </td>
            </tr>
        }
        @if (config.GetBoolean("TitleImageUrl1_EditVisible"))
        {
            var TitleImageUrl1_Display = string.IsNullOrEmpty(config.GetString("TitleImageUrl1_Display")) ? "图片" :
            config.GetString("TitleImageUrl1_Display");
            var TitleImageUrl1_Required = config.GetBoolean("TitleImageUrl1_Required");
            <tr>
                <th>
                    @if (TitleImageUrl1_Required)
                    {
                        <b>*</b>
                    }
                    @Html.LabelFor(model => model.TitleImageUrl1, TitleImageUrl1_Display)
                </th>
                <td>
                    <input id="TitleImageUrl1" name="TitleImageUrl1" style="display: none" value="@Html.Raw(Model.TitleImageUrl1)"
                           type="text">
                    <span class="span-btn" id="TitleImageUrl1Btn">上传图片</span>
                    <img id="TitleImageUrl1Img" style="width: 200px; min-height: 100px; margin-top: 10px;background: #f5f5f5"
                         src="@Html.Raw(Model.TitleImageUrl1)" alt="">

                    @* @Html.MyNet().UploadFor(model => model.TitleImageUrl1, new UploadOptions
                        {
                        AttachmentKey = Model.Id,
                        AttachmentTypeKey = "CMS_ArticleImage",
                        UploadMode = UploadMode.ImageSingle,
                        ImageWidth = config.GetIntNullable("TitleImageUrl1_Width"),
                        ImageHeight = config.GetIntNullable("TitleImageUrl1_Height"),
                        PreviewImageWidth = config.GetIntNullable("TitleImageUrl1_PreviewWidth"),
                        PreviewImageHeight = config.GetIntNullable("TitleImageUrl1_PreviewHeight"),
                        }, !TitleImageUrl1_Required ? null : new ValidateOptions
                        {
                        RequiredError = "请上传" + TitleImageUrl1_Display
                        })
                        @Html.MyNet().ValidationMessageFor(model => model.TitleImageUrl1) *@
                </td>
            </tr>
        }
        @if (config.GetBoolean("TitleImageUrl2_EditVisible"))
        {
            var TitleImageUrl2_Display = string.IsNullOrEmpty(config.GetString("TitleImageUrl2_Display")) ? "图片" :
            config.GetString("TitleImageUrl2_Display");
            var TitleImageUrl2_Required = config.GetBoolean("TitleImageUrl2_Required");
            <tr>
                <th>
                    @if (TitleImageUrl2_Required)
                    {
                        <b>*</b>
                    }
                    @Html.LabelFor(model => model.TitleImageUrl2, TitleImageUrl2_Display)
                </th>
                <td>
                    <input id="TitleImageUrl2" name="TitleImageUrl2" style="display: none" value="@Html.Raw(Model.TitleImageUrl2)"
                           type="text">
                    <span class="span-btn" id="TitleImageUrl2Btn">上传图片</span>
                    <img id="TitleImageUrl2Img" style="width: 200px; min-height: 100px; margin-top: 10px;background: #f5f5f5"
                         src="@Html.Raw(Model.TitleImageUrl2)" alt="">

                    @* @Html.MyNet().UploadFor(model => model.TitleImageUrl2, new UploadOptions
                        {
                        AttachmentKey = Model.Id,
                        AttachmentTypeKey = "CMS_ArticleImage",
                        UploadMode = UploadMode.ImageSingle,
                        ImageWidth = config.GetIntNullable("TitleImageUrl2_Width"),
                        ImageHeight = config.GetIntNullable("TitleImageUrl2_Height"),
                        PreviewImageWidth = config.GetIntNullable("TitleImageUrl2_PreviewWidth"),
                        PreviewImageHeight = config.GetIntNullable("TitleImageUrl2_PreviewHeight"),
                        }, !TitleImageUrl2_Required ? null : new ValidateOptions
                        {
                        RequiredError = "请上传" + TitleImageUrl2_Display
                        })
                        @Html.MyNet().ValidationMessageFor(model => model.TitleImageUrl2) *@
                </td>
            </tr>
        }
        @if (config.GetBoolean("Image_EditVisible"))
        {
            var Image_Display = string.IsNullOrEmpty(config.GetString("Image_Display")) ? "图片" :
            config.GetString("Image_Display");
            var Image_Required = config.GetBoolean("Image_Required");
            <tr>
                <th>
                    @if (Image_Required)
                    {
                        <b>*</b>
                    }
                    @Html.LabelFor(model => model.ImageUrl, Image_Display)
                </th>
                <td>
                    @*
                        @Html.MyNet().UploadFor(model => model.ImageUrl, new UploadOptions
                        {
                        AttachmentKey = Model.Id,
                        AttachmentTypeKey = "CMS_ArticleImage",
                        UploadMode = UploadMode.ImageMulti,
                        ImageWidth = config.GetIntNullable("Image_Width"),
                        ImageHeight = config.GetIntNullable("Image_Height"),
                        PreviewImageWidth = config.GetIntNullable("Image_PreviewWidth"),
                        PreviewImageHeight = config.GetIntNullable("Image_PreviewHeight"),
                        }, !Image_Required ? null : new ValidateOptions
                        {
                        RequiredError = "请上传" + Image_Display
                        })
                        @Html.MyNet().ValidationMessageFor(model => model.ImageUrl)
                    *@
                </td>
            </tr>
        }
        @if (config.GetBoolean("Video_EditVisible"))
        {
            var Video_Display = string.IsNullOrEmpty(config.GetString("Video_Display")) ? "视频" :
            config.GetString("Video_Display");
            var Video_Required = config.GetBoolean("Video_Required");
            <tr>
                <th>
                    @if (Video_Required)
                    {
                        <b>*</b>
                    }
                    @Html.LabelFor(model => model.Video, Video_Display)
                </th>
                <td style="margin-top: 10px">
                    @*@Html.MyNet().UploadFor(model => model.Video, new UploadOptions
                        {
                        AttachmentKey = Model.Id,
                        AttachmentTypeKey = "Video_AttachmentType",
                        UploadMode = UploadMode.FileSingle
                        }, !Video_Required ? null : new ValidateOptions
                        {
                        RequiredError = "请上传" + Video_Display
                        })
                        @Html.MyNet().ValidationMessageFor(model => model.Video)*@

                    @*data-val-required="请上传视频"*@
                    <input data-val="true" id="Video" @(Video_Required ? "data-val-required='请上传视频'" : "") placeholder="手动输入视频地址" name="Video"
                           style="display:block; margin-bottom: 10px; width: 300px; line-height: 1.8;" type="text"
                           value="@Model.Video">
                    <input type="file" id="uploadify_mpb1eb1a45ogbbvi">
                    <span id="progress-video"></span>
                    <div style="margin-top: 10px" id="video-view">
                        @if (@Model.Video != null)
                        {
                            <video muted controls style="width: 300px;" autoplay> <source id="source-view" src="@Model.Video" type="video/mp4"> </video>
                        }
                    </div>
                    <script>
                      document.getElementById('Video').onblur = function(e){
                        if(document.getElementById('source-view') && (document.getElementById('source-view').src === e.target.value)) {return};
                        document.getElementById('video-view').innerHTML = ''
                        let res = e.target.value || '';
                        document.getElementById('video-view').innerHTML ='<video  muted controls style="width: 300px;" autoplay> <source id="source-view" src="'+ res +'" type="video/mp4" > </video>';
                      }

                       let openBtn = true
                        document.getElementById('uploadify_mpb1eb1a45ogbbvi').onchange =async function (e) {
                          if(!openBtn) {
                            alert('上一个视频上传还未完成上传，请不要重复操作');
                            return
                          }
                          openBtn = false
                          document.getElementById('video-view').innerHTML = ''

                          const files = e.target.files;
                          if (!files) {
                            alert('视频上传文件获取失败');
                            penBtn = true
                            return;
                          }

                          let postFiles = Array.prototype.slice.call(files);
                          postFiles = postFiles.slice(0, 1);

                          if (postFiles.length === 0) return;

                          let file = postFiles[0]

                          if (!file) {
                            alert('视频上传文件获取失败');
                            penBtn = true
                            return;
                          }

                          let formData = new FormData();
                          formData.append(file.name, file);
                          console.log(formData)


                          if(parseInt(file.size/1024) > 204800){
                            alert('视频上传文件不能超过200M');
                            penBtn = true
                            return
                          }

                          let res = await  updateImg(file,false,document.getElementById('progress-video'))
                          openBtn = true
                          document.getElementById('video-view').innerHTML ='<video muted controls style="width: 300px;" autoplay> <source id="source-view" src="'+ res +'" type="video/mp4" > </video>';
                          document.getElementById('Video').value = res || ''
                        }

                      // jQuery(function () {
                      //   var remove = function (element) {
                      //     $(element).parent().remove();
                      //     $('#Video').val('');
                      //
                      //     //删除文件
                      //   };
                      //
                      //   var bind = function (fileUrl) {
                      //     if (!fileUrl && '@Model.Video' != "") {
                      //       fileUrl = '@Model.Video';
                      //     }
                      //
                      //     if (fileUrl) {
                      //       $("#links_mpb1eb1a45ogbbvi").html('<span><a target="_blank" href=' + fileUrl + '>文件</a><i>×</i></span>');
                      //
                      //       $('#Video').val(fileUrl);
                      //       $("#links_mpb1eb1a45ogbbvi i").unbind("click");
                      //       $("#links_mpb1eb1a45ogbbvi i").bind("click", function () {
                      //         remove(this);
                      //       });
                      //     }
                      //   };
                      //
                      //   $("#uploadify_mpb1eb1a45ogbbvi").uploadify(
                      //     {
                      //       auto: true,
                      //       multi: false,
                      //       width: 360,
                      //       height: 26,
                      //       buttonText: "选择文件",
                      //       swf: "/App_Content/Plugin/uploadify/uploadify.swf",
                      //       uploader: "/CMS/Commons/UploadFile",
                      //       fileTypeDesc: "文件",
                      //       fileTypeExts: "*.mp4",//*.mp4;*.b
                      //       fileSizeLimit: 1024 * 200,//限制上传大小200M
                      //       successTimeout: 300,//默认30秒，超过时间中断
                      //       onUploadSuccess: function (file, result, response) {
                      //         if (disposeException(result)) return;
                      //         bind(JSON.parse(result).Url);
                      //
                      //       }
                      //     });
                      //
                      //   bind();
                      // });
                    </script>
                    <div id="links_mpb1eb1a45ogbbvi" class="uploadify-links"></div>

                    <span class="field-validation-valid" data-valmsg-for="Video" data-valmsg-replace="true"></span>
                </td>
            </tr>
        }
        @if (config.GetBoolean("Topic_EditVisible"))
        {
            var Topic_Display = string.IsNullOrEmpty(config.GetString("Topic_Display")) ? "专题包附件" :
            config.GetString("Topic_Display");
            var Topic_Required = config.GetBoolean("Topic_Required");
            <tr>
                <th>
                    @if (Topic_Required)
                    {
                        <b>*</b>
                    }
                    @Html.LabelFor(model => model.TopicDecompressUrl, Topic_Display)
                </th>
                <td>
                    @Html.MyNet().UploadFor(model => model.TopicDecompressUrl, new UploadOptions
                    {
                        AttachmentKey = Model.Id,
                        AttachmentTypeKey = "CMS_ArticleTopic",
                        UploadMode = UploadMode.FileSingle
                    }, !Topic_Required ? null : new ValidateOptions
                    {
                        RequiredError = "请上传" + Topic_Display
                    })
                    @Html.MyNet().ValidationMessageFor(model => model.TopicDecompressUrl)
                </td>
            </tr>
        }
        @if (config.GetBoolean("City_EditVisible"))
        {
            if (create)
            {
                Model.City = config.GetIntNullable("City_Value");
            }
            var City_Display = string.IsNullOrEmpty(config.GetString("City_Display")) ? "城市" :
            config.GetString("Topic_Display");
            var City_Required = config.GetBoolean("City_Required");
            <tr>
                <th>
                    @if (City_Required)
                    {
                        <b>*</b>
                    }
                    @Html.LabelFor(model => model.City, City_Display)
                </th>
                <td>
                    @Html.MyNet().DropDownEnumListFor(model => model.City, "CMS_City", "请选择" + City_Display,
                                                                                                                                                            !City_Required ? null : new ValidateOptions
                                                                                                                                                            {
                                                                                                                                                                RequiredError = "请输入" + City_Display
                                                                                                                                                            })
                    @Html.MyNet().ValidationMessageFor(model => model.City)
                </td>
            </tr>
        }
        @if (config.GetBoolean("PublishTime_EditVisible"))
        {
            if (create)
            {
                Model.PublishTime = config.GetDateTimeNullable("PublishTime_Value");
            }
            var PublishTime_Display = string.IsNullOrEmpty(config.GetString("PublishTime_Display")) ? "发布时间" :
            config.GetString("PublishTime_Display");
            var PublishTime_Required = config.GetBoolean("PublishTime_Required");
            <tr>
                <th>
                    @if (PublishTime_Required)
                    {
                        <b>*</b>
                    }
                    @Html.LabelFor(model => model.PublishTime, PublishTime_Display)
                </th>
                <td>
                    @Html.MyNet().DateTimePickerFor(model => model.PublishTime, new DateTimeOptions
                    {
                        DefaultNow = true
                    }, !PublishTime_Required ? null : new ValidateOptions
                    {
                        RequiredError = "请输入" + PublishTime_Display
                    })
                    @{
                        var day = (Model.PublishTime.GetValueOrDefault() - DateTime.Now).Days + 1;
                    }
                    <span>
                        定时发布：
                        @for (int i = 1; i < 8; i++)
                        {
                            <span onclick="changePublishTime(this,@(i))" class='@(day==i?"hdayd":"dayd")'>@(i)天</span>
                        }
                    </span>
                    @Html.MyNet().ValidationMessageFor(model => model.PublishTime)
                </td>
            </tr>
        }

        @if (!isQPHSH)
        {
            if (config.GetBoolean("ViewCount_EditVisible"))
            {
                if (create)
                {
                    Model.ViewCount = config.GetInt("ViewCount_Value");
                }
                var ViewCount_Display = string.IsNullOrEmpty(config.GetString("ViewCount_Display")) ? "查看数" :
                config.GetString("ViewCount_Display");
                var ViewCount_Required = config.GetBoolean("ViewCount_Required");
                <tr>
                    <th>
                        @if (ViewCount_Required)
                        {
                            <b>*</b>
                        }
                        @Html.LabelFor(model => model.ViewCount, ViewCount_Display, !ViewCount_Required ? null : new
                                                                                                                                                             ValidateOptions
                        {
                            RequiredError = "请输入" + ViewCount_Display
                        })
                    </th>
                    <td>
                        @Html.MyNet().IntegerTextBoxFor(model => model.ViewCount)
                        @Html.MyNet().ValidationMessageFor(model => model.ViewCount)
                    </td>
                </tr>
            }
            if (config.GetBoolean("CycleAddViewCount_EditVisible"))
            {
                if (create)
                {
                    Model.CycleAddViewCount = config.GetInt("CycleAddViewCount_Value");
                }
                var CycleAddViewCount_Display = string.IsNullOrEmpty(config.GetString("CycleAddViewCount_Display")) ?
                "每小时自动新增阅读数" : config.GetString("CycleAddViewCount_Display");
                var CycleAddViewCount_Required = config.GetBoolean("CycleAddViewCount_Required");
                <tr>
                    <th>
                        @if (CycleAddViewCount_Required)
                        {
                            <b>*</b>
                        }
                        @Html.LabelFor(model => model.CycleAddViewCount, CycleAddViewCount_Display,
                                                                                                                                                             !CycleAddViewCount_Required ? null : new ValidateOptions
                                                                                                                                                             {
                                                                                                                                                                 RequiredError = "请输入" + CycleAddViewCount_Display
                                                                                                                                                             })
                    </th>
                    <td>
                        @Html.MyNet().IntegerTextBoxFor(model => model.CycleAddViewCount) (每次随机 + -10)
                        @Html.MyNet().ValidationMessageFor(model => model.CycleAddViewCount)
                    </td>
                </tr>
            }
            if (config.GetBoolean("LikeCount_EditVisible"))
            {
                if (create)
                {
                    Model.LikeCount = config.GetInt("LikeCount_Value");
                }
                var LikeCount_Display = string.IsNullOrEmpty(config.GetString("LikeCount_Display")) ? "点赞数" :
                config.GetString("LikeCount_Display");
                var LikeCount_Required = config.GetBoolean("LikeCount_Required");
                <tr>
                    <th>
                        @if (LikeCount_Required)
                        {
                            <b>*</b>
                        }
                        @Html.LabelFor(model => model.LikeCount, LikeCount_Display, !LikeCount_Required ? null : new
                                                                                                                                                             ValidateOptions
                        {
                            RequiredError = "请输入" + LikeCount_Display
                        })
                    </th>
                    <td>
                        @Html.MyNet().IntegerTextBoxFor(model => model.LikeCount)
                        @Html.MyNet().ValidationMessageFor(model => model.LikeCount)
                    </td>
                </tr>
            }
            if (config.GetBoolean("CycleAddLikeCount_EditVisible"))
            {
                if (create)
                {
                    Model.CycleAddLikeCount = config.GetInt("CycleAddLikeCount_Value");
                }
                var CycleAddLikeCount_Display = string.IsNullOrEmpty(config.GetString("CycleAddLikeCount_Display")) ?
                "每小时自动新增点赞数" : config.GetString("CycleAddLikeCount_Display");
                var CycleAddLikeCount_Required = config.GetBoolean("CycleAddLikeCount_Required");
                <tr>
                    <th>
                        @if (CycleAddLikeCount_Required)
                        {
                            <b>*</b>
                        }
                        @Html.LabelFor(model => model.CycleAddLikeCount, CycleAddLikeCount_Display,
                                                                                                                                                             !CycleAddLikeCount_Required ? null : new ValidateOptions
                                                                                                                                                             {
                                                                                                                                                                 RequiredError = "请输入" + CycleAddLikeCount_Display
                                                                                                                                                             })
                    </th>
                    <td>
                        @Html.MyNet().IntegerTextBoxFor(model => model.CycleAddLikeCount) (每次随机 + -10)
                        @Html.MyNet().ValidationMessageFor(model => model.CycleAddLikeCount)
                    </td>
                </tr>
            }
            if (config.GetBoolean("CycleTimes_EditVisible"))
            {
                if (create)
                {
                    Model.CycleTimes = config.GetInt("CycleTimes_Value");
                }
                var CycleTimes_Display = string.IsNullOrEmpty(config.GetString("CycleTimes_Display")) ? "总循环次数" :
                config.GetString("CycleTimes_Display");
                var CycleTimes_Required = config.GetBoolean("CycleTimes_Required");
                <tr>
                    <th>
                        @if (CycleTimes_Required)
                        {
                            <b>*</b>
                        }
                        @Html.LabelFor(model => model.CycleTimes, CycleTimes_Display, !CycleTimes_Required ? null : new
                                                                                                                                                             ValidateOptions
                        {
                            RequiredError = "请输入" + CycleTimes_Display
                        })
                    </th>
                    <td>
                        @Html.MyNet().IntegerTextBoxFor(model => model.CycleTimes)
                        @Html.MyNet().ValidationMessageFor(model => model.CycleTimes)
                    </td>
                </tr>
            }
            if (config.GetBoolean("CycleCompletionTimes_EditVisible"))
            {
                if (create)
                {
                    Model.CycleCompletionTimes = config.GetInt("CycleCompletionTimes_Value");
                }
                var CycleCompletionTimes_Display = string.IsNullOrEmpty(config.GetString("CycleCompletionTimes_Display")) ?
                "已完成次数" : config.GetString("CycleCompletionTimes_Display");
                var CycleCompletionTimes_Required = config.GetBoolean("CycleCompletionTimes_Required");
                <tr>
                    <th>
                        @if (CycleCompletionTimes_Required)
                        {
                            <b>*</b>
                        }
                        @Html.LabelFor(model => model.CycleCompletionTimes, CycleCompletionTimes_Display,
                                                                                                                                                             !CycleCompletionTimes_Required ? null : new ValidateOptions
                                                                                                                                                             {
                                                                                                                                                                 RequiredError = "请输入" + CycleCompletionTimes_Display
                                                                                                                                                             })
                    </th>
                    <td>
                        @Html.MyNet().IntegerTextBoxFor(model => model.CycleCompletionTimes)
                        @Html.MyNet().ValidationMessageFor(model => model.CycleCompletionTimes)
                    </td>
                </tr>
            }
            if (config.GetBoolean("CommentCount_EditVisible"))
            {
                if (create)
                {
                    Model.CommentCount = config.GetInt("CommentCount_Value");
                }
                var CommentCount_Display = string.IsNullOrEmpty(config.GetString("CommentCount_Display")) ? "评论数" :
                config.GetString("CommentCount_Display");
                var CommentCount_Required = config.GetBoolean("CommentCount_Required");
                <tr>
                    <th>
                        @if (CommentCount_Required)
                        {
                            <b>*</b>
                        }
                        @Html.LabelFor(model => model.CommentCount, CommentCount_Display, !CommentCount_Required ? null :
                                                                                                                                                             new ValidateOptions
                                                                                                                                                             {
                                                                                                                                                                 RequiredError = "请输入" + CommentCount_Display
                                                                                                                                                             })
                    </th>
                    <td>
                        @Html.MyNet().IntegerTextBoxFor(model => model.CommentCount)
                        @Html.MyNet().ValidationMessageFor(model => model.ViewCount)
                    </td>
                </tr>
            }
        }
        else
        {
            if (config.GetBoolean("ViewCount_EditVisible"))
            {
                if (create)
                {
                    Model.ViewCount = config.GetInt("ViewCount_Value");
                }
                @Html.MyNet().HiddenFor(model => model.ViewCount)
            }
            if (config.GetBoolean("CycleAddViewCount_EditVisible"))
            {
                if (create)
                {
                    Model.CycleAddViewCount = config.GetInt("CycleAddViewCount_Value");
                }
                @Html.MyNet().HiddenFor(model => model.CycleAddViewCount)
            }
            if (config.GetBoolean("LikeCount_EditVisible"))
            {
                if (create)
                {
                    Model.LikeCount = config.GetInt("LikeCount_Value");
                }
                @Html.MyNet().HiddenFor(model => model.LikeCount)
            }
            if (config.GetBoolean("CycleAddLikeCount_EditVisible"))
            {
                if (create)
                {
                    Model.CycleAddLikeCount = config.GetInt("CycleAddLikeCount_Value");
                }
                @Html.MyNet().HiddenFor(model => model.CycleAddLikeCount)
            }
            if (config.GetBoolean("CycleTimes_EditVisible"))
            {
                if (create)
                {
                    Model.CycleTimes = config.GetInt("CycleTimes_Value");
                }
                @Html.MyNet().HiddenFor(model => model.CycleTimes)
            }
            if (config.GetBoolean("CycleCompletionTimes_EditVisible"))
            {
                if (create)
                {
                    Model.CycleCompletionTimes = config.GetInt("CycleCompletionTimes_Value");
                }
                @Html.MyNet().HiddenFor(model => model.CycleCompletionTimes)

            }
            if (config.GetBoolean("CommentCount_EditVisible"))
            {
                if (create)
                {
                    Model.CommentCount = config.GetInt("CommentCount_Value");
                }
                @Html.MyNet().HiddenFor(model => model.CommentCount)

            }
        }

        @if (config.GetBoolean("SortIndex_EditVisible"))
        {
            if (create)
            {
                Model.SortIndex = config.GetInt("SortIndex_Value");
            }
            var SortIndex_Display = string.IsNullOrEmpty(config.GetString("SortIndex_Display")) ? "排序" :
            config.GetString("SortIndex_Display");
            var SortIndex_Required = config.GetBoolean("SortIndex_Required");
            <tr>
                <th>
                    @if (SortIndex_Required)
                    {
                        <b>*</b>
                    }
                    @Html.LabelFor(model => model.SortIndex, SortIndex_Display, !SortIndex_Required ? null : new
                                                                                                                                                            ValidateOptions
                    {
                        RequiredError = "请输入" + SortIndex_Display
                    })
                </th>
                <td>
                    @Html.MyNet().IntegerTextBoxFor(model => model.SortIndex)
                    @Html.MyNet().ValidationMessageFor(model => model.ViewCount)
                </td>
            </tr>
        }
        else
        {
            @Html.HiddenFor(model => model.SortIndex)
        }
        @if (config.GetBoolean("IsCommend_EditVisible") || config.GetBoolean("IsHot_EditVisible") ||
config.GetBoolean("IsTop_EditVisible"))
        {
            <tr>
                <th></th>
                <td class="checkbox">
                    @if (config.GetBoolean("IsCommend_EditVisible"))
                    {
                        if (create)
                        {
                            Model.IsCommend = config.GetBoolean("IsCommend_Value");
                        }
                        @Html.CheckBoxFor(model => model.IsCommend)
                        @Html.LabelFor(model => model.IsCommend, string.IsNullOrEmpty(config.GetString("IsCommend_Display"))
                                                                                                                                                                ?
                                                                                                                                                                "推荐" :
                                                                                                                                                                config.GetString("IsCommend_Display"))
                    }
                    @if (config.GetBoolean("IsHot_EditVisible"))
                    {
                        if (create)
                        {
                            Model.IsHot = config.GetBoolean("IsHot_Value");
                        }
                        @Html.CheckBoxFor(model => model.IsHot)
                        @Html.LabelFor(model => model.IsHot, string.IsNullOrEmpty(config.GetString("IsHot_Display")) ?
                                                                                                                                                                "热门" :
                                                                                                                                                                config.GetString("IsHot_Display"))
                    }
                    @if (config.GetBoolean("IsTop_EditVisible"))
                    {
                        if (create)
                        {
                            Model.IsTop = config.GetBoolean("IsTop_Value");
                        }
                        @Html.CheckBoxFor(model => model.IsTop)
                        @Html.LabelFor(model => model.IsTop, string.IsNullOrEmpty(config.GetString("IsTop_Display")) ?
                                                                                                                                                                "置顶" :
                                                                                                                                                                config.GetString("IsTop_Display"))
                    }
                </td>
            </tr>
        }
        @if (config.GetBoolean("Summary_EditVisible"))
        {
            if (create)
            {
                Model.Summary = config.GetString("Summary_Value");
            }
            var Summary_Display = string.IsNullOrEmpty(config.GetString("Summary_Display")) ? "摘要" :
            config.GetString("Summary_Display");
            var Summary_Required = config.GetBoolean("Summary_Required");
            <tr>
                <th>
                    @if (Summary_Required)
                    {
                        <b>*</b>
                    }
                    @Html.LabelFor(model => model.Summary, Summary_Display)
                </th>
                <td>
                    @Html.MyNet().TextAreaFor(model => model.Summary, !Summary_Required ? null : new ValidateOptions
                    {
                        RequiredError = "请输入" + Summary_Display,
                        LengthMax = 1000
                    })
                    @Html.MyNet().ValidationMessageFor(model => model.Summary)
                </td>
            </tr>
        }
        @if (config.GetBoolean("ExtField01_EditVisible"))
        {
            if (create)
            {
                Model.ExtField01 = config.GetString("ExtField01_Value");
            }
            var ExtField01_Display = string.IsNullOrEmpty(config.GetString("ExtField01_Display")) ? "扩展字段一" :
            config.GetString("ExtField01_Display");
            var ExtField01_Required = config.GetBoolean("ExtField01_Required");
            <tr>
                <th>
                    @if (ExtField01_Required)
                    {
                        <b>*</b>
                    }
                    @Html.LabelFor(model => model.ExtField01, ExtField01_Display)
                </th>
                <td>
                    @Html.MyNet().TextBoxFor(model => model.ExtField01, !ExtField01_Required ? null : new
                                                                                                                                                            ValidateOptions
                    {
                        RequiredError = "请输入" + ExtField01_Display,
                        LengthMax = 256
                    })
                    @Html.MyNet().ValidationMessageFor(model => model.ExtField01)
                </td>
            </tr>
        }
        @if (config.GetBoolean("ExtField02_EditVisible"))
        {
            if (create)
            {
                Model.ExtField02 = config.GetString("ExtField02_Value");
            }
            var ExtField02_Display = string.IsNullOrEmpty(config.GetString("ExtField02_Display")) ? "扩展字段二" :
            config.GetString("ExtField02_Display");
            var ExtField02_Required = config.GetBoolean("ExtField02_Required");
            <tr>
                <th>
                    @if (ExtField02_Required)
                    {
                        <b>*</b>
                    }
                    @Html.LabelFor(model => model.ExtField02, ExtField02_Display)
                </th>
                <td>
                    @Html.MyNet().TextBoxFor(model => model.ExtField02, !ExtField02_Required ? null : new
                                                                                                                                                            ValidateOptions
                    {
                        RequiredError = "请输入" + ExtField02_Display,
                        LengthMax = 256
                    })
                    @Html.MyNet().ValidationMessageFor(model => model.ExtField02)
                </td>
            </tr>
        }
        @if (config.GetBoolean("ExtField03_EditVisible"))
        {
            if (create)
            {
                Model.ExtField03 = config.GetString("ExtField03_Value");
            }
            var ExtField03_Display = string.IsNullOrEmpty(config.GetString("ExtField03_Display")) ? "扩展字段三" :
            config.GetString("ExtField03_Display");
            var ExtField03_Required = config.GetBoolean("ExtField03_Required");
            <tr>
                <th>
                    @if (ExtField03_Required)
                    {
                        <b>*</b>
                    }
                    @Html.LabelFor(model => model.ExtField03, ExtField03_Display)
                </th>
                <td>
                    @Html.MyNet().TextBoxFor(model => model.ExtField03, !ExtField03_Required ? null : new
                                                                                                                                                            ValidateOptions
                    {
                        RequiredError = "请输入" + ExtField03_Display,
                        LengthMax = 256
                    })
                    @Html.MyNet().ValidationMessageFor(model => model.ExtField03)
                </td>
            </tr>
        }
        @if (config.GetBoolean("ExtField04_EditVisible"))
        {
            if (create)
            {
                Model.ExtField04 = config.GetString("ExtField04_Value");
            }
            var ExtField04_Display = string.IsNullOrEmpty(config.GetString("ExtField04_Display")) ? "扩展字段四" :
            config.GetString("ExtField04_Display");
            var ExtField04_Required = config.GetBoolean("ExtField04_Required");
            <tr>
                <th>
                    @if (ExtField04_Required)
                    {
                        <b>*</b>
                    }
                    @Html.LabelFor(model => model.ExtField04, ExtField04_Display)
                </th>
                <td>
                    @Html.MyNet().TextBoxFor(model => model.ExtField04, !ExtField04_Required ? null : new
                                                                                                                                                            ValidateOptions
                    {
                        RequiredError = "请输入" + ExtField04_Display,
                        LengthMax = 256
                    })
                    @Html.MyNet().ValidationMessageFor(model => model.ExtField04)
                </td>
            </tr>
        }
        @if (config.GetBoolean("Text_EditVisible"))
        {
            if (create)
            {
                //Model.Text = config.GetString("Text_Value");
            }
            var Text_Display = string.IsNullOrEmpty(config.GetString("Text_Display")) ? "内容" :
            config.GetString("Text_Display");
            var Text_Required = config.GetBoolean("Text_Required");
            <tr>
                <th>
                    @if (Text_Required)
                    {
                        <b>*</b>
                    }
                    @Html.LabelFor(model => model.Text, string.IsNullOrEmpty(config.GetString("Text_Display")) ?
                                                                                                                                                            "内容" :
                                                                                                                                                            config.GetString("Text_Display"))
                </th>
                <td>
                    <input style="display: none" type="text" Name="text" id="edit-text">
                    <div class="wangEdit-wrap">
                        <div class="syl-editor-toolbar">
                            <div id="div1" class="syl-toolbar">
                            </div>
                        </div>

                        <!--<div class="publish-editor-title publish-editor-title">-->
                        <!--<div class="publish-editor-title-inner">-->
                        <!--<div class="editor-title autofit-textarea-wrapper">-->
                        <!--<textarea id="title-textarea" placeholder="请输入文章标题（0-30个汉字）" autocomplete="off"></textarea>-->
                        <!--</div>-->
                        <!--<span class="title-tip"><span class="cur">12</span> / 30</span>-->
                        <!--</div>-->
                        <!--</div>-->

                        <div id="div3"></div>
                    </div>
                </td>
            </tr>
            <script type="text/javascript" src="~/App_Content/Script/OA/axios.js"></script>
            <script type="text/javascript" src="~/App_Content/Script/OA/wangEditor.js"></script>
            <script type="text/javascript" src="~/App_Content/Script/OA/cropper.min.js"></script>
            <script type="text/javascript" src="~/App_Content/Script/OA/ajax.js"></script>
            <script type="text/javascript" src="~/App_Content/Script/OA/libs.js"></script>
            <script type="text/javascript" src="~/App_Content/Script/OA/axios-action.js"></script>
            <script type="text/javascript" src="~/App_Content/Script/OA/edit-action.js"></script>
            <script type="text/javascript" src="~/App_Content/Script/OA/img-action.js"></script>
            <script type="text/javascript">
              var text = '@Html.Raw(Model.Text)';
              console.log(Object.prototype.toString.call(text))

              if(text) {
                text = unescape(text)
              }

              editor.txt.html(matchImg(text));
              // editor.txt.html(text);

              setTimeout(function () {
                uploadImgs()
              },300);

              // editor.txt.html('<p>用 JS 设置的内容</p>')
              var menuToolId = editor.toolbarElemId;

              let colorMenu = editor.$toolbarElem.children()[7];
              let bgMenu = editor.$toolbarElem.children()[8];

              colorMenu.onmousemove = function (e) {
                e.preventDefault()

                let listEl = colorMenu.querySelector('.w-e-droplist')
                if (!listEl || listEl.style.width === '320px') return

                listEl.style.width = '320px'
              };

              bgMenu.onmousemove = function (e) {
                e.preventDefault()
                let listEl = bgMenu.querySelector('.w-e-droplist')
                if (!listEl || listEl.style.width === '320px') return

                listEl.style.width = '320px'
              };

              let imgMenu = document.getElementById(editor.imgMenuId);
              imgMenu.onclick = function (e) {
                let buttonEl = document.querySelector('.w-e-panel-container .w-e-panel-tab-content .w-e-button-container');
                let button = document.createElement('button');
                button.innerText = '本地上传';
                buttonEl.appendChild(button);
                button.onclick = function (e) {
                  e.preventDefault();
                  document.querySelector('.pop-up-model').style.display = "flex";
                  openActionBtn('本地上传');
                }
              };
              clickImg();


              editText = document.getElementById('edit-text');

            </script>
        }

    </table>

}
<style>
    .form .k-textbox { width: 100%; }

    .form textarea.k-textbox { width: 100%; }

    .checkbox label { margin-right: 5px; }

    .dayd { background: #CCC; color: white; cursor: pointer; padding: 5px; }

    .hdayd { background: orange; color: white; cursor: pointer; padding: 5px; }
</style>
<script type="text/javascript" src="~/App_Content/Script/OA/cropper.min.js"></script>
<script type="text/javascript" src="~/App_Content/Script/OA/ajax.js"></script>
<script type="text/javascript" src="~/App_Content/Script/OA/libs.js"></script>
<script type="text/javascript" src="~/App_Content/Script/OA/img-action.js"></script>
<script type="text/javascript">
            upBtn('TitleImageUrl')
            upBtn('TitleImageUrl1')
            upBtn('TitleImageUrl2')
            upBtn('TitleImageUrl3')
          upBtn('ImageUrl')

          function insertHtml(type) {
            var editor = UE.getEditor($('.editor textarea')[0].id);
            var htmlTmp = [
              '<div class=\"cb right\"><img src=\"/App_Attachment/UnAuthorizationFolder/Common_EditorImage/84859bd4-1baa-413a-a1fb-4c27a3e71b3a.jpg?20180209192419\" title=\"2\" /><br /><em class=\"big-num\" style=\"background-color:#fff\">1</em> 课程描述课程描述课程描述课程描述课程描述课程描述课程描述课程描述 课程描述课程描述课程描述课程描述课程描述课程描述课程描述课程描述 课程描述课程描述课程描述课程描述课程描述课程描述课程描述课程描述 课程描述课程描述课程描述课程描述课程描述课程描述课程描述课程描述<div class=\"clear\"></div></div><div class=\"cb left\" style=\"padding-top:20px;\"><img src=\"/App_Attachment/UnAuthorizationFolder/Common_EditorImage/84859bd4-1baa-413a-a1fb-4c27a3e71b3a.jpg?20180209192419\" title=\"2\" /><br /><em class=\"big-num\" style=\"background-color:#fff;padding-top:9px;\">2</em> 课程描述课程描述课程描述课程描述课程描述课程描述课程描述课程描述 课程描述课程描述课程描述课程描述课程描述课程描述课程描述课程描述 课程描述课程描述课程描述课程描述课程描述课程描述课程描述课程描述 课程描述课程描述课程描述课程描述课程描述课程描述课程描述课程描述 课程描述课程描述课程描述课程描述课程描述课程描述课程描述课程描述<div class=\"clear\"><br /></div></div>'

              , '<div class=\"cb right\"><img src=\"/App_Attachment/UnAuthorizationFolder/Common_EditorImage/84859bd4-1baa-413a-a1fb-4c27a3e71b3a.jpg?20180209192419\" title=\"2\" /><p>1、标题1</p><p>2、标题2</p><p>3、标题3</p><div class=\"clear\"></div></div><div class=\"cb left\" style=\"padding-top:20px;\"><img src=\"/App_Attachment/UnAuthorizationFolder/Common_EditorImage/84859bd4-1baa-413a-a1fb-4c27a3e71b3a.jpg?20180209192419\" title=\"2\" /><p>1、标题1</p><p>2、标题2</p><p>3、标题3</p></div></div>'
            ];
            var h = editor.getContent();
            editor.setContent(h + htmlTmp[type]);
          }

          /**/
          var isBackThis = '@isBackThis' == 'True';

          /**/

          function save() {
            if (editText != '') {
              editText.value = saveEdit(editor);
              // console.log('查看',editText.value);
            }

            var form = $("form");
            console.log(form);
            sync(form);

            if (!form.valid()) return;

            $.ajax({
              url: form.attr("action"),
              data: form.serialize(),
              type: "post",
              error: disposeError,
              success: function (result) {
                if (disposeException(result)) return;
                if (isBackThis) {
                  backThis();
                } else {
                  back(true);
                }
              }
            });
          };

          function changePublishTime(elem, day) {
            $(elem).addClass("hdayd");
            $(elem).siblings().removeClass("hdayd").addClass("dayd");
            var now = new Date();
            now.setDate(now.getDate() + day);


            $('#PublishTime').val(dateFormat("YYYY/mm/dd HH:MM", now));
          }

          function dateFormat(fmt, date) {
            let ret;
            const opt = {
              "Y+": date.getFullYear().toString(),        // 年
              "m+": (date.getMonth() + 1).toString(),     // 月
              "d+": date.getDate().toString(),            // 日
              "H+": date.getHours().toString(),           // 时
              "M+": date.getMinutes().toString(),         // 分
              "S+": date.getSeconds().toString()          // 秒
              // 有其他格式化字符需求可以继续添加，必须转化成字符串
            };
            for (let k in opt) {
              ret = new RegExp("(" + k + ")").exec(fmt);
              if (ret) {
                fmt = fmt.replace(ret[1], (ret[1].length == 1) ? (opt[k]) : (opt[k].padStart(ret[1].length, "0")))
              }
              ;
            }
            ;
            return fmt;
          }

          $('input[type=radio][name=TitleImageTypeGroup]').change(function () {
              if (this.value == '0') {
                  $('#oneImage').show();
                  $('#moreImage').hide();
              }
              else if (this.value == '1') {
                  $('#oneImage').hide();
                  $('#moreImage').show();
              }
          });

          $('input[type=radio][name=LiveStatusGroup]').change(function () {
              if (this.value == '2') {
                  $('.liveInfo').hide();
              }
              else {
                  $('.liveInfo').show();
              }
          });
</script>
